<template>
  <div class="dashboard-container">
    <nav class="side-nav">
      <div class="nav-header">
        <h2>健康数据管理系统</h2>
      </div>
      <div class="nav-links">
        <router-link to="/dashboard/overview" class="nav-item" active-class="active">
          总览
        </router-link>
        <router-link to="/dashboard/heatmap" class="nav-item" active-class="active">
          城市热力图查看
        </router-link>
        <router-link to="/dashboard/user-analysis" class="nav-item" active-class="active">
          用户群体分析
        </router-link>
        <router-link to="/dashboard/ticket" class="nav-item" active-class="active">
          故障处理工单
        </router-link>
      </div>
      <button class="logout-btn" @click="handleLogout">退出登录</button>
    </nav>
    <main class="main-content">
      <router-view />
    </main>
  </div>
</template>

<script setup>
import { useRouter } from 'vue-router';
import { useAuthStore } from '../stores/auth';
const router = useRouter();
const authStore = useAuthStore();
const handleLogout = () => {
  authStore.logout();
  router.push('/login');
};
</script>

<style scoped>
.dashboard-container {
  display: flex;
  min-height: 100vh;
  background-color: #f5f6fa;
}
.side-nav {
  width: 200px;
  background-color: #2c3e50;
  color: white;
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
}
.nav-header {
  padding: 20px;
  text-align: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.nav-header h2 {
  font-size: 1.2em;
  margin: 0;
}
.nav-links {
  flex: 1;
  padding: 20px 0;
}
.nav-item {
  display: block;
  padding: 12px 20px;
  color: white;
  text-decoration: none;
  transition: background-color 0.3s;
}
.nav-item:hover {
  background-color: rgba(255, 255, 255, 0.1);
}
.nav-item.active {
  background-color: #34495e;
  border-left: 4px solid #42b983;
}
.logout-btn {
  margin: 20px;
  padding: 10px;
  background-color: #e74c3c;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.3s;
}
.logout-btn:hover {
  background-color: #c0392b;
}
.main-content {
  flex: 1;
  margin-left: 200px;
  min-height: 100vh;
  width: calc(100% - 200px);
  display: flex;
  background-color: #f5f6fa;
  padding: 0;
  box-sizing: border-box;
}
.main-content > :deep(*) {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
</style>